import {axios, baseURL} from "./base/axios.config";
// 用户板块（系统用户、会员、角色、权限）的接口封装
export default {
    login(params) {
        return axios.post('/api/users/login', params);
        /*
        如果要跳转到其它平台去登录可以这样
        let returnUrl = returnUrl || `${location.origin}/admin`;
        location.href = `${loginBaseUrl}/sys/login?returnUrl=${returnUrl}&remember=false`;
        */
    },
    logout() {
        return axios.post('/api/users/logout');
        /*
        如果要跳转到其它平台去退出可以这样
        let returnUrl = returnUrl || `${location.origin}/admin`;
        location.href = `${loginBaseUrl}/sys/loginOut?returnUrl=${location.origin}/?from=logout`; // from=logout参数用于跳回来清token
        */
    },

    //用户管理
    getUsers(params) {
        return axios.post('/api/users/getAll', params);
    },
    saveUser(params) {
        return axios.post('/api/users/saveUser', params);
    },
    getUserEditDto(id){
        return axios.post('/api/users/getUserEditDto', {id:id});
    },
    delete(id) {
        return axios.post('/api/users/delete', {id:id});
    },

    //角色、权限管理
    saveRole(params) {
        return axios.post('/api/roles/save', params);
    },
    getRoles(params) {
        return axios.post('/api/roles/getAll', params);
    },
    deleteRole(id) {
        return axios.post('/api/roles/delete', {id:id});
    },
}
